//index.js
//获取应用实例
var app = getApp()
Page({
    data: {
       dataList:[]
    },

    onLoad: function (options) {
        console.log(options);//传递过来的参数
        var that = this;
        wx.showLoading({
            title: '加载中',
            mask: true
        });
        //调用应用实例的方法获取全局数据
        var wxthis = this;
        wx.request({
            url: 'https://mb.800151.com/phalapi/Public/applet/?service=Demo.demoList',
            data: {

            },
            header: {
                'content-type': 'application/json'
            },
            success: function (res) {
                console.log(res);
                if (res.data.ret != 200) {
                    console.log(res.data.msg)
                }
                console.log(res.data.data)
                // console.log(res);
                //设置列表数据
                wxthis.setData({
                    dataList: res.data.data
                });
                wx.hideLoading();
            }
        })
    },

    delClick:function (e) {
        wx.showLoading({
            title: '删除中',
            mask: true
        });
        let _id = e.currentTarget.dataset.id;
        wx.request({
            url: 'https://mb.800151.com/phalapi/Public/applet/?service=Demo.demoDel',
            data: {
                id:_id
            },
            header: {
                'content-type': 'application/json'
            },
            success: function (res) {
                if (res.data.ret != 200) {
                    wx.showModal({
                        title: '提示',
                        content: res.data.msg,
                        showCancel: false
                    });
                    console.log(res.data.msg)
                }

                wx.showModal({
                    title: '提示',
                    content: '删除成功',
                    showCancel: false
                });

                wx.hideLoading();


            }
        })
    },

    sxClick:function (e) {
        wx.navigateTo({
            url: '../demo/index'
        })
    },

    indexClick:function (e) {
        wx.navigateTo({
            url: '../index/index'
        })
    },


    onReady: function () {
        // 页面渲染完成
    },
    onShow: function () {
        // 页面显示
    },
    onHide: function () {
        // 页面隐藏
    },
    onUnload: function () {
        // 页面关闭
    }
})
